package edu.syr.iis.web.model;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;

import edu.syr.iis.web.util.HibernateUtil;

public class AnnotationAssignmentManager 
{
	private static Log log = LogFactory.getLog(MessageManager.class);
	
	public List<AnnotationAssignment> getAnnotationAssignments(User user)
	{
		List<AnnotationAssignment> list = null;
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();

		try
		{
			list = session.createQuery("FROM AnnotationAssignment aa" +
					" WHERE aa.user = :user" +
			" ORDER BY aa.annotationAssignmentId")
			.setEntity("user", user)
			.list(); 		
			session.getTransaction().commit();
		}
		catch (HibernateException e)
		{
			session.getTransaction().rollback();
			throw e;
		}
		return list;
	}
	

}
